package cn.t.web.android;

import cn.t.annotation.Runtime;
import cn.t.dto.android.DeviceHeartbeatDTO;
import cn.t.facade.device.HeartbeatFacade;
import cn.t.runtime.dto.HeartBeatRequest;
import cn.t.runtime.dto.HeartBeatResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author l
 */
@Slf4j
@RestController
@RequestMapping("runtime")
@AllArgsConstructor
@Runtime
public class AndroidBaseController {


    @PostMapping("/heartbeat")
    public HeartBeatResponse heartbeat(@RequestBody HeartBeatRequest request) {

        HeartBeatResponse response = new HeartBeatResponse();
        DeviceHeartbeatDTO heartbeat = heartbeatFacade.heartbeat(request);
        response.setToken(heartbeat.getToken());

        return response;
    }


    @Autowired
    private HeartbeatFacade heartbeatFacade;

}
